package mobi.greenplate.client.service.response;

import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import mobi.greenplate.client.connect.DefaultResponseHandler;
import mobi.greenplate.client.domain.Address;
import mobi.greenplate.client.handler.AddressListHandler;
import mobi.greenplate.client.parser.DomainParser;

/**
 *
 * @author dmakariev
 */
public class AddressListResponseHandler extends DefaultResponseHandler {

    private List<Address> addressList;

    public List<Address> getAddressList() {
        return Collections.unmodifiableList(addressList);
    }

    @Override
    public void handleContent(InputStream inputStream, long contentLength) {
        final AddressListHandler addressListHandler = new AddressListHandler();
        final DomainParser<List<Address>> addressParser = DomainParser.newInstance(addressListHandler);
        addressList = addressParser.parse(inputStream);
    }
}
